#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <string>
using namespace std;
void *fun(void *p)
{
    string name = static_cast<const char *>(p);
    int n = 5;
    while (n--)
    {
        sleep(1);
        cout << "I am " << name << endl;
    }
    pthread_exit(nullptr);
    cout<<"666"<<endl;
    return nullptr;
}
int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, fun, (void *)"thread-1");
    int n = pthread_join(tid, nullptr);
    if (n != 0)
        cout << "fail" << endl;
    else
        cout << "success" << endl;
    return 0;
}